fix: refreshToken 검증 누락(Critical) + 카카오 500→401 수정 (prod) - #222
Merged
Conversation
AuthService(getNewToken/signIn) 13개, AppleSignInService(P8 키 파싱/ 잘못된 idToken) 3개, 총 16개 신규 테스트. 테스트 작성 중 발견해서 수정한 버그: 1. [Critical] AuthService.getNewToken: refreshToken을 재발급받을 때 Redis에 "무언가 저장돼 있는지"만 확인하고, 요청으로 들어온 refreshToken이 실제로 그 저장된 값과 일치하는지는 비교하지 않고 있었음. 재로그인 등으로 이미 새 refreshToken이 발급되어 Redis 값이 교체된 이후에도, 예전 refreshToken이 만료 전이기만 하면 계속 accessToken 재발급에 쓰일 수 있었던 상태 — refreshToken 무효화가 사실상 작동하지 않고 있었음. 저장된 값과 요청값을 직접 비교하도록 수정. 2. KakaoSignInService.getSocialInfo: 카카오 API 호출(RestTemplate.exchange)이 try-catch 밖에 있어서, 카카오 토큰이 만료/무효해 카카오 서버가 4xx를 반환하면(흔한 케이스) RestTemplate이 던지는 예외가 그대로 새어나가 401(UnauthorizedException) 대신 500으로 처리되고 있었음. API 호출을 try 블록 안으로 이동. 추가로 signIn()의 디버그용 System.out.println 제거. ## dev에 누락돼있던 기존 보안 수정 반영 AppleSignInService의 Apple ID 토큰 서명 검증 로직이 dev에는 없었음. PR #202(main으로 직접 hotfix, 2026-07-28)로 이미 고쳐졌던 건인데 dev로는 한 번도 반영이 안 된 채 남아있었음 — dev에서 계속 개발하면 서명 검증 없이 파싱만 하는 취약한 버전으로 되돌아간 상태였음. main의 c74b4ab 커밋을 그대로 cherry-pick해서 dev에도 반영.
unam98
requested review from
RinRinPARK,
YuSuhwa-ve and
funnysunny08
as code owners
August 5, 2026 11:19
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
작업 배경
변경 사항
AuthService.getNewTokenAuthService.signInSystem.out.println제거KakaoSignInService.getSocialInfoAuthServiceTest,AppleSignInServiceTest영향 범위
getNewToken이 지금까지 Redis에 "뭔가 저장돼 있는지"만 확인하고 있어서, 재로그인 등으로 이미 무효화된 예전 refreshToken도 JWT 자체 만료 전까지는 계속 accessToken 재발급에 쓰일 수 있었음. 지금 이 순간 prod에도 동일하게 해당됨 — 이 PR로 실제 저장된 최신 토큰과 일치할 때만 재발급되도록 막힘.검증 매트릭스
redis에_저장된_값이_없음•
redis에_저장된_값과_다름정상_재발급•
accessToken_무효•
refreshToken_만료•
refreshToken_무효•
클레임이_숫자가_아님•
존재하지_않는_유저신규_회원가입•
기존_유저_로그인•
애플_로그인•
닉네임_중복시_재생성•
잘못된_provider유효한_EC_비밀키면_정상적으로_파싱된다•
잘못된_형식의_비밀키면_UnauthorizedException•
idToken이_JWT_형식이_아니면_UnauthorizedExceptionTest Plan
docker run으로 임시 DB/Redis 띄워서./gradlew build전체(ServerApplicationTests 포함) 통과 확인🤖 Generated with Claude Code